package com.xx.springboot.entity;

/**
 * Created by xiaoxiunique on 2018-8-6.
 */

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.List;


@Component("out")
@Scope("prototype")
public class CommonResult extends SuperEntity<CommonResult> {
    /**
     * 错误
     */
    public static final Integer STATUS_ERROR = -1;
    /**
     * 失败
     */
    public static final Integer STATUS_FAILURE = 0;
    /**
     * 正常
     */
    public static final Integer STATUS_SUCCESS = 1;
    /**
     * 用户名为空
     */
    public static final Integer USER_USERNAME_EMPTY = 4001;
    /**
     * 用户名重复
     */
    public static final Integer USER_USERNAME_REPEAT = 4000;
    /**
     * 用户密码为空
     */
    public static final Integer USER_USERPWD_EMPTY = 4002;
    /**
     * 用户密码应该在6-20位之间
     */
    public static final Integer USER_USERPWD_LENGTH_ERR = 4003;
    /**
     * 登陆失败
     */
    public static final Integer USER_USERLOGIN_ERROR = 4004;
    /**
     * 登陆成功
     */
    public static final Integer USER_USERLOGIN_SUCCESS = 4005;
    /**
     * 返回的状态
     */
    private Integer stats;
    /**
     * 信息内容
     */
    private String message;
    private int totalPage;
    private List TotalPageList;
    /**
     * 主题
     */
    private Object main;
    private Object list;

    /**
     * 商户
     */
    private Object others;

    private CommonResult(Builder builder) {
        this.stats = builder.stats;
        this.message = builder.message;
        this.totalPage = builder.totalPage;
        this.TotalPageList = builder.TotalPageList;
        this.main = builder.main;
        this.list = builder.list;
        this.others = builder.others;
    }

    public Object getOthers() {
        return others;
    }

    public void setOthers(Object others) {
        this.others = others;
    }

    public CommonResult() {
        this(STATUS_SUCCESS, "", null, null);
    }

    public CommonResult(Integer stats, String message, Object main, Object list) {
        super();
        this.stats = stats;
        this.message = message;
        this.main = main;
        this.list = list;
    }

    public CommonResult(Integer stats, String message) {
        this(stats, message, null, null);
    }

    public Integer getStats() {
        return stats;
    }
    public void setStats(Integer stats) {
        this.stats = stats;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public Object getMain() {
        return main;
    }
    public void setMain(Object main) {
        this.main = main;
    }

    public Object getList() {
        return list;
    }

    public void setList(Object list) {
        this.list = list;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public List getTotalPageList() {
        return TotalPageList;
    }

    public void setTotalPageList(List totalPageList) {
        TotalPageList = totalPageList;
    }


    public static class Builder {
        private Integer stats;
        private String message;
        private int totalPage;
        private List TotalPageList;
        private Object main;
        private Object list;

        private Object others;

        public Builder withStats(Integer stats) {
            this.stats = stats;
            return this;
        }

        public Builder withMessage(String message) {
            this.message = message;
            return this;
        }

        public Builder withTotalPage(int totalPage) {
            this.totalPage = totalPage;
            return this;
        }

        public Builder withTotalPageList(List totalPageList) {
            TotalPageList = totalPageList;
            return this;
        }

        public Builder withMain(Object main) {
            this.main = main;
            return this;
        }

        public Builder withList(Object list) {
            this.list = list;
            return this;
        }

        public Builder withOthers(Object others) {
            this.others = others;
            return this;
        }

        public CommonResult build() {
            return new CommonResult(this);
        }
    }
}
